<?php
/*
* Description: File used by Dynamic Data Management object to block/unblock calendars
*/

include('../../../appg/settings.php');
include('../../../appg/init_ajax.php');
include('Class.CalendarManager.php');
$PostBackKey = ForceIncomingString('PostBackKey', '');
$ExtensionKey = ForceIncomingString('ExtensionKey', '');
if ($PostBackKey != '' && $PostBackKey == $Context->Session->GetVariable('SessionPostBackKey', 'string')) {
	$Block = ForceIncomingBool('Block', 0);
	$BlockCalendarID = ForceIncomingInt('BlockCalendarID', 0);

	if ($BlockCalendarID > 0) {
		$CalendarManager = $Context->ObjectFactory->NewContextObject($Context, 'CalendarManager');
		if ($Block) {
			$CalendarManager->AddCalendarBlock($BlockCalendarID);
		} else {
			$CalendarManager->RemoveCalendarBlock($BlockCalendarID);
		}
	}
	// Report success
	echo 'Complete';
} else {
	echo $Context->GetDefinition('ErrPostBackKeyInvalid');
}
$Context->Unload();
?>